home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / editor / snmp_0_1.zip / snmp-0.1 / aka / snmp / Access.java < prev    next >
Text File  |  1997-06-09  |  2KB  |  106 lines

  1. /*
  2. Snmp Library
  3. Copyright (C) 1997 Alex Kowalenko Associates Pty Ltd. All rights reserved.
  4.  
  5. $Id: Access.java,v 1.4 1997/05/21 10:09:56 alex Exp $
  6.  
  7. This software maybe be free distributed, any any form, without fee, 
  8. but may not be modified in any way without express permission of 
  9. the directors of Alex Kowalenko Associates Pty Ltd. 
  10.  
  11. Alex Kowalenko Associates Pty Ltd makes no representations or
  12. warranties about the suitabililty of the software, not even the
  13. implied warranty of merchantability or fitness for any particular
  14. purpose.    
  15. */
  16.  
  17. package aka.snmp;
  18.  
  19. /**
  20.  * Thee SNMP Access Attribute
  21.  * @version     $Id: Access.java,v 1.4 1997/05/21 10:09:56 alex Exp $
  22.  * @author      Alex Kowalenko
  23.  */
  24.  
  25. import java.io.*;
  26.  
  27. public class Access implements Serializable {
  28.  
  29.     final static int VOID = -1;
  30.     final static int READ_ONLY = 1;
  31.     final static int READ_WRITE = 2;
  32.     final static int WRITE_ONLY = 3;
  33.     final static int NOT_ACCESSIBLE = 4;
  34.  
  35.   private int _value;
  36.  
  37. /**
  38.  * Default Constructor   
  39.  */
  40.     
  41.   public Access() {
  42.       _value = VOID;
  43.   };
  44.     
  45. /**
  46.  * Constructor from the integer representation 
  47.  */
  48.     
  49.   public Access(int theAccess) {
  50.       _value = theAccess;
  51.   };
  52.  
  53. /** 
  54.  * Constructor from the string representation
  55.  */
  56.     
  57.   public Access(String string) {
  58.       if(string.equals("read-only"))
  59.       _value = READ_ONLY;
  60.       else if(string.equals("read-write"))
  61.       _value = READ_WRITE;
  62.       else if(string.equals("write-only"))
  63.       _value = WRITE_ONLY;
  64.       else if(string.equals("not-accessiable"))
  65.       _value = READ_ONLY;
  66.       else _value = VOID;
  67.   };
  68.     
  69. /**
  70.  * Return the integer representation
  71.  */
  72.     
  73.   public int value() {
  74.       return _value;
  75.   };
  76.     
  77. /**
  78.  * Return string representation
  79.  */
  80.  
  81.   public String toString() {
  82.       switch( _value) {
  83.     case READ_ONLY: 
  84.       return "Read Only";
  85.     case READ_WRITE:
  86.       return "Read Write";
  87.     case WRITE_ONLY:
  88.       return "Write Only";
  89.     case NOT_ACCESSIBLE:
  90.       return "Not Accessible";
  91.       }
  92.       return "Unknown";
  93.   }
  94.  
  95. /**
  96.  * Test Harness
  97.  */
  98.   
  99.     static public void main(String args[]) {
  100.     Access s = new Access();
  101.     System.out.println(s);
  102.     s = new Access(Access.WRITE_ONLY);
  103.     System.out.println(s);
  104.     }
  105. }
  106.